package fr.umlv.m2.jee.spij.service.lesson;

import fr.umlv.m2.jee.spij.service.ldap.authentification.DisplayActor;
import org.springframework.binding.message.MessageContext;

import java.util.List;

/**
 * Provides services about lessons.
 *
 * @author thomas magny
 */
public interface IDisplayLessonService {

    /**
     * Returns all the lessons given for a unit.
     *
     * @param unitId the unit foreign key
     *
     * @return a list of DTO that contains the displayed data
     */
    public List<DisplayLesson> getAllDisplayLesson(final long unitId,
                                                   MessageContext context);

    /**
     * Returns all the lessons given for an user.
     *
     * @param unitId the unit foreign key
     *
     * @return a list of DTO that contains the displayed data
     */
    public List<DisplayLesson> getAllDisplayLessonPerUser(final long unitId,
                                                          DisplayActor currentUser,
                                                          MessageContext context);

    /**
     * Returns displayed datas about specific lesson
     *
     * @param id the lesson primary key
     *
     * @return the data to display
     */
    public DisplayLesson getLessonById(final long id,
                                       MessageContext context);

    /**
     * Creates a new lesson to persist into database. The new lesson is
     * assigned to a single unit according to the {@code Long} given in argument.
     *
     * @param displayLesson contains the data to create the new lesson
     * @param unitId        the unit foreign key
     * @param context       message context
     *
     * @return true whether the lesson has been created or false otherwise
     */
    public boolean createLesson(final DisplayLesson displayLesson,
                                final long unitId,
                                final MessageContext context);

    /**
     * Updates a lesson with datas given into DisplayLesson object
     *
     * @param context        the message context
     * @param modifiedLesson the modified data
     *
     * @return true whether the lesson has been updated or false otherwise
     */
    public boolean updateLessonById(final DisplayLesson modifiedLesson,
                                    final MessageContext context);

    /**
     * Removes a lesson according to its primary key.
     *
     * @param id      the primary key
     * @param context the message context
     *
     * @return true whether the lesson has been well removed or false
     *         otherwise.
     */
    public boolean deleteLessonById(final long id,
                                    final MessageContext context);

    /**
     * @param createdLesson
     * @param context
     * @param fileData
     *
     * @return
     */
    public boolean uploadLesson(DisplayLesson createdLesson,
                                MessageContext context,
                                byte[] fileData);

}
